#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\res\new.ico
#AutoIt3Wrapper_Outfile=out\install-wub.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.16.1
 Author:         myName

 Script Function:
	Template AutoIt script.

#ce ----------------------------------------------------------------------------
#include <MsgBoxConstants.au3>
;#include <FileConstants.au3>
;#include <StringConstants.au3>
#include <AltasConstants.au3>
#include <InetConstants.au3>

Local $sFilePath = "Wub.exe"
;RunWait("curl " & $server & $sFilePath & " -o " &$sFilePath, @TempDir , @SW_HIDE)
InetGet($http_server & $sFilePath , @TempDir & "\" & $sFilePath, $INET_FORCERELOAD + $INET_IGNORESSL , $INET_DOWNLOADWAIT )
;ShellExecute(@TempDir)
FileMove( @TempDir & "\" &$sFilePath, $workingdir  & "\" &$sFilePath   , $FC_OVERWRITE   + $FC_CREATEPATH)
;Exit
Local $iInstallerFileExists = FileExists($workingdir &"\" &$sFilePath)

; Display a message of whether the file exists or not.
If $iInstallerFileExists Then
	;MsgBox($MB_SYSTEMMODAL, "", "The file exists." & @CRLF & "FileExist returned: " & $iInstallerFileExists)
Else
	MsgBox($MB_SYSTEMMODAL, "", "The file ("&$sFilePath&")doesn't exist." & @CRLF & "FileExist returned: " & $iInstallerFileExists)
	Exit
EndIf


; -------------------------------- Main ------------------------------------
ShellExecute($workingdir)

;Run("wireguard-amd64-0.5.3.msi")
;ShellExecuteWait(@ScriptDir & "\" & $sInstallerFilePath)
Local $iPID = RunWait ($workingdir & "\" &$sFilePath, $workingdir)
Local $hWnd = WinWaitActive("Windows Update Blocker v1.8", "Windows Updates Option", 3)
;ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:2]")
ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:3]")
ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:4]")
ControlClick($hWnd, "", "[CLASS:Button; INSTANCE:5]")
Sleep(1500)
Local $hWnd = WinKill("Windows Update Blocker v1.8","")
ConsoleWrite($hWnd& "---winkill ------>" &$iPID &"----" & @CRLF)
ProcessClose($iPID)

Sleep(1500)
; Delete the temporary file.
Local $res = FileDelete($sFilePath)
Local $res = FileDelete("Wub.*")
ConsoleWrite($res& "---delete ------>"& @CRLF)
